package com.liuning.OtherFunction;

/**
 * 测试守护线程
 */
public class TestDaemon {
    public static void main(String[] args) {
        God god = new God();
        You you = new You();

        Thread thread = new Thread(god);
        //默认是false表示是用户线程，正常的线程都是用户线程
        thread.setDaemon(true);

        thread.start();

        //用户线程
        new Thread(you).start();
    }
}

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("God run ...");
        }
    }
}

class You implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("still alive");
        }
        System.out.println("end...");
    }
}
